import com.town.pojo.Student;
import com.town.pojo.User;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MyTest1 {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("userbeans.xml");
//        User user = (User) context.getBean("user");
        User user = context.getBean("user",User.class);
        System.out.println(user.toString());

    }
    @Test
    public void test2(){
        ApplicationContext context = new ClassPathXmlApplicationContext("userbeans.xml");
        User user = context.getBean("user1",User.class);
        System.out.println(user);
    }


    //bean的作用域：默认是单例模式，（spring默认模式）
    //原型模式：每次从容器中get的时候，都会产生一个新对象
    //requesu session application
    @Test
    public void test3(){
        ApplicationContext context = new ClassPathXmlApplicationContext("userbeans.xml");
        User user = context.getBean("user",User.class);
        User user1 = context.getBean("user1",User.class);
        System.out.println(user.hashCode());
        System.out.println(user1.hashCode());
        System.out.println(user==user1);
    }
}
